<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  props: {
    info: { type: Object, required: true },
  },
});
</script>

<template>
  <view class="product-item">
    <image
      class="product-item-img"
      :src="info.pic_url"
      mode="aspectFill"
      lazy-load
      :style="{
        height:
          info.order_type === 2 || info.order_type === 8
            ? '184rpx'
            : info.order_type === 3
            ? '254rpx'
            : '208rpx',
      }"
    />
    <view class="product-item-content">
      <view class="product-item-name">{{ info.product_name }}</view>
      <view class="product-item-tag">{{ info.tag }}</view>

      <view style="display: flex; align-items: center; width: 100%">
        <view class="product-item-price">
          <view class="product-item-price2">¥</view>{{ info.min_price }}
          <view class="product-item-price3">起</view>
        </view>
        <view class="product-item-num">{{ info.sold_count_str }}</view>
      </view>
    </view>
  </view>
</template>

<style lang="scss">
.product-item {
  display: flex;

  .product-item-img {
    flex-shrink: 0;
    width: 208rpx;
    border-radius: 20rpx;
  }

  .product-item-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex-grow: 1;
    min-width: 0;
    margin-left: 20rpx;
  }

  .product-item-name {
    max-height: 80rpx;
    margin-bottom: 10rpx;
    font-size: 28rpx;
    color: #2d2d2d;
    line-height: 40rpx;
    font-weight: bold;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .product-item-tag {
    padding: 0 8rpx;
    margin-bottom: auto;
    font-size: 22rpx;
    color: #ffa300;
    line-height: 36rpx;
    border-radius: 10rpx;
    border: 2rpx solid rgba(255, 163, 0, 0.25);
    background-color: #fffaf1;
  }

  .product-item-price {
    display: flex;
    align-items: flex-end;
    font-size: 36rpx;
    color: #fa6400;
    line-height: 40rpx;
    font-weight: bold;
  }

  .product-item-price2 {
    margin-right: 4rpx;
    font-size: 22rpx;
    line-height: 32rpx;
  }

  .product-item-price3 {
    margin-left: 4rpx;
    font-size: 24rpx;
    color: #666666;
    line-height: 34rpx;
    font-weight: 400;
  }

  .product-item-num {
    margin-left: 20rpx;
    font-size: 24rpx;
    color: #999999;
    line-height: 34rpx;
  }
}
</style>